package szcg.scheduled.service.task;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import szcg.scheduled.service.service.TaskHandleService;

/**
 * 该接口会在程序启动后被后台调用
 */
@Component
public class CommandTask implements CommandLineRunner {
    private static final Logger logger = LoggerFactory.getLogger(CommandTask.class);

    private final TaskHandleService taskHandleService;

    public CommandTask(TaskHandleService taskHandleService) {
        this.taskHandleService = taskHandleService;
    }

    @Override
    public void run(String... args) throws Exception {
        logger.warn("=======>ScheduledApplication启动完成<=======");
        taskHandleService.startTaskForPersistence();
    }
}
